git rename remote branch

To rename a remote branch, you must delete the old branch name and push the new one. Follow these steps:

1. Rename the local branch

If you are already on the branch:

git branch -m <new-name>

If you are on a different branch:

git branch -m <old-name> <new-name>

2. Delete the old branch on the remote and push the new one

git push origin :<old-name> <new-name>

3. Reset the upstream branch for the new local branch

git push origin -u <new-name>

Summary Table

Action Command
Rename Local git branch -m <new-name>
Delete Remote git push origin --delete <old-name>
Push New git push origin <new-name>
Set Upstream git push origin -u <new-name>